import Vue from 'vue'
import vuex from 'vuex'
import Cloudbase from "@cloudbase/vue-provider"
Vue.use(Cloudbase, {
    env: "gdmecst-test-5rmth"
});
Vue.use(vuex);

const store =new vuex.Store({
    state:{
        Authorization: localStorage.getItem('Authorization')?localStorage.getItem('Authorization'):'',
        Utter:'1',
        tx:'',
        admin:false,
        article_id:''
    },
    mutations:{
        changeLogin(state,user){
            state.authorization=user.Authorization;
            localStorage.setItem('Authorization',user.Authorization)
        },
        updateUtter(state,utter){
            state.Utter = utter
        },
        async updateTx(state,txurl){
            state.tx = txurl
        },
        updateAdmin(state,admin){
            state.admin=admin
        }
    },
    actions:{
        updateUtterFun(context,v){
            context.commit('getUtter',v)
        },
        updateTxFun(context,v){
            context.commit('updateTx',v)
        },
        updateAdminFun(context,v){
            context.commit('updateAdmin',v)
        }
    }
})

export default store;